// 下载文件
export function downloadFile(res, fileName = '导出信息.xlsx') {
  return new Promise((resolve, reject) => {
    const content = res
    const blob = new Blob([content])
    if ('download' in document.createElement('a')) { // 非IE下载
      try {
        const elink = document.createElement('a')
        elink.download = fileName
        elink.style.display = 'none'
        elink.href = URL.createObjectURL(blob)
        document.body.appendChild(elink)
        elink.click()
        URL.revokeObjectURL(elink.href) // 释放URL 对象
        document.body.removeChild(elink)
        resolve()
      } catch {
        reject()
      }
    } else { // IE10+下载
      navigator.msSaveBlob(blob, fileName)
      resolve()
    }
  })
}
